/**
 * 
 */
package any.desktop;

import java.io.FileReader;
import java.io.IOException;
import java.io.Serializable;
import java.util.Properties;

import org.apache.commons.lang.Validate;

/**
 * @author keke <keke@codehaus.org>
 * @version
 * @revision $Revision:$
 */
public class Config implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 5661758351141186081L;
    private String            configFile;
    private Properties        properties;

    public String getProperty(final String key) {
        return properties.getProperty(key);
    }

    public String getProperty(final String key, final String defaultValue) {
        return properties.getProperty(key, defaultValue);
    }

    public void init() throws IOException {
        configFile = System
                .getProperty("desktop.config", "./conf/desktop.conf");
        Validate.notEmpty(configFile,
                "Need to setup desktop configuration first");
        properties = new Properties();
        properties.load(new FileReader(configFile));
    }

}
